#ifndef BOARD_H_
#define BOARD_H_

//class Queue;
// #include "queue.h"
#include "stdint.h"
// #include "data_holder.h"

enum USART_NUMBERs
{
    USART_0,
    USART_1,
    USART_2,
    USART_3,
    USART_4,
    USART_5
};

enum I2C_NUMBERs
{
    I2C_0,
    I2C_1,
};

enum MOTOR_ID
{
    WALKING_MOTOR1 = 0,
    WALKING_MOTOR2,
    PUMP_MOTOR,
};

enum MOTOR_DIRECTION
{
    MOTOR_DIRECTION_FORWARD = 0,
    MOTOR_DIRECTION_BACKWARD,
};

enum GPIO_OUTPUT_ID
{
    RUN_LED,
    LED_R,
    LED_G,
    LED_B,
    POWER_CONTROL
};

enum GPIO_INPUT_ID
{
    POWER_SWITCH
};

// class Board
// {
// public:
//     virtual void init() = 0;
//     virtual void check_running() = 0;
//     virtual void enable_irq() = 0;
//     // virtual void disable_irq() = 0;
//     virtual void usart_debug_init() = 0;
//     virtual void usart_init(unsigned char num, unsigned long buad) = 0;
//     virtual Queue *usart_getDataQueue(unsigned char num) = 0;

//     virtual void usart_write(unsigned char num, unsigned char ch) = 0;
//     virtual void usart_write(unsigned char num, unsigned char *data, unsigned short len) = 0;
//     virtual void led_init(unsigned int *data_buffer, unsigned short data_size) = 0;
//     virtual void led_signal_dma_transmit(unsigned int *data_buffer, unsigned int data_size) = 0;
//     // virtual void set_config(unsigned char *data, unsigned short len) = 0;
//     // virtual void get_config(unsigned char *data, unsigned short len) = 0;
//     // virtual void get_config(unsigned char *data) = 0;

//     virtual unsigned long get_tick_count() = 0;

//     virtual void setDOState(unsigned char led_id, unsigned char operation) = 0;
//     virtual bool getDIState(unsigned char id) = 0;

//     virtual void motor_init() = 0;
//     virtual void set_motor_direction(unsigned char num, unsigned char direction) = 0;
//     virtual void motor_pwm(unsigned char num, short pwm_value, unsigned short min_pwm) = 0;
//     // virtual void encoder_init(unsigned char motor_id) = 0;
//     // virtual long get_encoder_count(unsigned char motor_id) = 0;
//     virtual float get_adc_data(unsigned char n) = 0;

//     virtual void i2c_init(unsigned char num) = 0;
//     virtual unsigned char i2c_write_byte(unsigned char num, unsigned char equipment_address, unsigned char reg_address, unsigned char pt_char) = 0;
//     virtual unsigned char i2c_write_buf(unsigned char num, unsigned char equipment_address, unsigned char reg_address, unsigned char *pt_char, unsigned char size) = 0;
//     virtual unsigned char i2c_read_byte(unsigned char num, unsigned char equipment_address, unsigned char reg_address, unsigned char *pt_char) = 0;
//     virtual unsigned char i2c_read_buf(unsigned char num, unsigned char equipment_address, unsigned char reg_address, unsigned char *pt_char, unsigned char size) = 0;

//     unsigned char i2c_write_bit(unsigned char num, unsigned char equipment_address, unsigned char reg_address, unsigned char bitNum, unsigned char data)
//     {
//         unsigned char b = 0;
//         i2c_read_byte(num, equipment_address, reg_address, &b);
//         b = (data != 0) ? (b | (1 << bitNum)) : (b & ~(1 << bitNum));
//         return i2c_write_byte(num, equipment_address, reg_address, b);
//     }

//     unsigned char i2c_write_bits(unsigned char num, unsigned char devAddr, unsigned char regAddr, unsigned char bitStart, unsigned char length, unsigned char data)
//     {
//         unsigned char b;
//         if (i2c_read_byte(num, devAddr, regAddr, &b) != 0)
//         {
//             unsigned char mask = ((1 << length) - 1) << (bitStart - length + 1);
//             data <<= (bitStart - length + 1); // shift data into correct position
//             data &= mask;                     // zero all non-important bits in data
//             b &= ~(mask);                     // zero all important bits in existing byte
//             b |= data;                        // combine data with existing byte
//             return i2c_write_byte(num, devAddr, regAddr, b);
//         }
//         else
//         {
//             return 0;
//         }
//     }

//     int i2c_read_bits(unsigned char num, unsigned char devAddr, unsigned char regAddr, unsigned char bitStart, unsigned char length, unsigned char *data)
//     {
//         unsigned char count, b;
//         if ((count = i2c_read_byte(num, devAddr, regAddr, &b)) != 0)
//         {
//             unsigned char mask = ((1 << length) - 1) << (bitStart - length + 1);
//             b &= mask;
//             b >>= (bitStart - length + 1);
//             *data = b;
//         }
//         return count;
//     }

//     virtual bool spi_write_byte(uint8_t address, uint8_t *pData, uint32_t timeout) = 0;
//     virtual void spi_start(void) = 0;
//     virtual void spi_end(void) = 0;
//     virtual void spi_read(uint8_t address, uint8_t *pData, uint16_t Size) = 0;
//     virtual bool spi_erase_all(uint32_t timeout) = 0;

//     // virtual uint8_t SReadEepromTestData(void) = 0;
//     // virtual void SRead8DemarcateData(uint8_t address, unsigned char *parameter) = 0;
//     // virtual void SRead16DemarcateData(uint8_t address, short *parameter) = 0;
//     // virtual void SRead32DemarcateData(uint8_t address, float *parameter) = 0;
//     // virtual void SSave8DemarcateData(unsigned char parameter, uint8_t address) = 0;
//     // virtual void SSave16DemarcateData(short parameter, uint8_t address) = 0;
//     // virtual void SSave32DemarcateData(float parameter, uint8_t address) = 0;
//     // virtual void SSaveEepromTestData(uint8_t testdata) = 0;
//     // virtual void SEraseALL(void) = 0;
//     // virtual void save_imu_bias(long *a_bias, long *g_bias) = 0;
//     // virtual void save_running_period(long running_period) = 0;
//     virtual void GetUID(unsigned char UID[12]) = 0;
//     virtual void delay_ms(uint32_t t) = 0;
//     virtual void delay_us(uint32_t t) = 0;
//     virtual unsigned int get_micros() = 0;
//     virtual void set_interrupt_vector_table() = 0;
//     virtual int save_ota_flag(uint8_t flag, uint32_t fw_size = 0) = 0;
//     virtual uint16_t get_flash_size(void) = 0;
//     virtual uint32_t read_ota_flag(void) = 0;
//     virtual uint8_t read_ota_flag_type(void) = 0;
//     virtual uint32_t read_ota_size(void) = 0;
//     virtual void mcu_reset(void) = 0;
//     virtual bool is_software_reset(void) = 0;
//     static Board *get();
// };

#endif
